package com.ivr.cm.dao.impl;

import org.springframework.jdbc.core.support.JdbcDaoSupport;

import com.ivr.cm.dao.IUserBillDao;
import com.ivr.cm.service.BaseServiceIF;
import com.ivr.cm.util.BaseUtil;
import com.ivr.cm.vo.UserBillVo;
/**
 * 账单数据实现
 * @author liugeng
 * @date 2015-12-15
 * @version 1.0
 */
public class UserBillDaoImpl extends JdbcDaoSupport implements IUserBillDao, BaseServiceIF<Object> {

	@Override
	public int doProcess(Object obj) {
		if(obj instanceof UserBillVo){
			return insertUserBill((UserBillVo)obj);
		}
		return 0;
	}
	/**保存用户账单数据*/
	@Override
	public int insertUserBill(UserBillVo userBillVo) {
		String sql = "insert into tb_ivr_user_bill(mobile,sp_number,province,city,time_begin,time_end,second,minute,fee_number,linkId,lower_id,router_id,isfilter) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
		Object[] param = new Object[]{userBillVo.getMobile(),userBillVo.getSp_number(),
									userBillVo.getProvince(),userBillVo.getCity(),
									userBillVo.getTime_begin(),userBillVo.getTime_end(),
									userBillVo.getSecond(),userBillVo.getMinute(),
									userBillVo.getFee_number(),userBillVo.getLinkId(),
									userBillVo.getLower_id(),userBillVo.getRouter_id(),
									userBillVo.getIsfilter()};
		logger.info(String.format("保存用户账单数据[%s]", BaseUtil.logSQL(sql, param)));
		int count = this.getJdbcTemplate().update(sql, param);
		return count;
	}
}
